home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / tvmenu.arc / HELLO.PAS next >
Pascal/Delphi Source File  |  1990-12-17  |  3KB  |  111 lines

  1. {**************************************************}
  2. { Demo program for the TCheckMarkMenuBar object,   }
  3. { which implements a checkmark toggle on pulldown  }
  4. { menus.                                           }
  5. {   by Danny Thorpe                                }
  6. {   Copyright (c) 1990 by Borland International    }
  7. {                                                  }
  8. {**************************************************}
  9.  
  10. program Hello;
  11.  
  12. uses Objects, Drivers, Views, Menus, MoreMenu, Dialogs, App;
  13.  
  14. const
  15.   GreetThemCmd = 100;
  16.  
  17.   cmToggleTest = MarkStart;
  18.   cmSetTest = cmToggleTest + 1;
  19.   cmClearTest = cmToggleTest + 2;
  20.  
  21.  
  22. type
  23.   PHelloApp = ^THelloApp;
  24.   THelloApp = object(TApplication)
  25.     procedure GreetingBox;
  26.     procedure HandleEvent(var Event: TEvent); virtual;
  27.     procedure InitMenuBar; virtual;
  28.     procedure InitStatusLine; virtual;
  29.   end;
  30.  
  31. { THelloApp }
  32. procedure THelloApp.GreetingBox;
  33. var
  34.   R: TRect;
  35.   D: PDialog;
  36.   C: Word;
  37. begin
  38.   { Create a dialog }
  39.   R.Assign(25, 5, 55, 16);
  40.   D := New(PDialog, Init(R, 'Hello, World!'));
  41.  
  42.   { Create and insert controls into the dialog}
  43.   R.Assign(3, 5, 15, 6);
  44.   D^.Insert(New(PStaticText, Init(R, 'How are you?')));
  45.  
  46.   R.Assign(16, 2, 28, 4);
  47.   D^.Insert(New(PButton, Init(R, 'Terrific', cmCancel, bfNormal)));
  48.  
  49.   R.Assign(16, 4, 28, 6);
  50.   D^.Insert(New(PButton, Init(R, 'Ok', cmCancel, bfNormal)));
  51.  
  52.   R.Assign(16, 6, 28, 8);
  53.   D^.Insert(New(PButton, Init(R, 'Lousy', cmCancel, bfNormal)));
  54.  
  55.   R.Assign(16, 8, 28, 10);
  56.   D^.Insert(  New(PButton, Init(R, 'Cancel', cmCancel, bfNormal)));
  57.  
  58.   { Execute the modal dialog }
  59.   C := DeskTop^.ExecView(D);
  60. end;
  61.  
  62. procedure THelloApp.HandleEvent(var Event: TEvent);
  63. begin
  64.   TApplication.HandleEvent(Event);
  65.   if Event.What = evCommand then
  66.   begin
  67.     case Event.Command of
  68.       GreetThemCmd: GreetingBox;
  69.     else
  70.       Exit;
  71.     end;
  72.     ClearEvent(Event);
  73.   end;
  74. end;
  75.  
  76. procedure THelloApp.InitMenuBar;
  77. var
  78.   R: TRect;
  79. begin
  80.   GetExtent(R);
  81.   R.B.Y := R.A.Y + 1;
  82.   MenuBar := New(PCheckMarkMenuBar, Init(R, NewMenu(
  83.     NewSubMenu('~H~ello', hcNoContext, NewMenu(
  84.       NewItem('~G~reeting...','', 0, GreetThemCmd, hcNoContext,
  85.       NewLine(
  86.       NewItem('  ~T~est', '', kbNoKey, cmToggleTest, hcNoContext,
  87.       NewItem('E~x~it', 'Alt-X', kbAltX, cmQuit, hcNoContext,
  88.       nil))))), nil))));
  89. end;
  90.  
  91. procedure THelloApp.InitStatusLine;
  92. var
  93.   R: TRect;
  94. begin
  95.   GetExtent(R);
  96.   R.A.Y := R.B.Y-1;
  97.   StatusLine := New(PStatusLine, Init(R,
  98.     NewStatusDef(0, $FFFF,
  99.       NewStatusKey('', kbF10, cmMenu,
  100.       NewStatusKey('~Alt-X~ Exit', kbAltX, cmQuit, nil)), nil)));
  101. end;
  102.  
  103. var
  104.   HelloWorld: THelloApp;
  105.  
  106. begin
  107.   HelloWorld.Init;
  108.   HelloWorld.Run;
  109.   HelloWorld.Done;
  110. end.
  111.